# -*- encoding: utf-8 -*-
'''
@文件    :addone.py
@说明    :
@时间    :2020/06/02 10:33:55
@作者    :张钧铭
'''

class Solution(object):
    def plusOne(self, digits):
        """
        :type digits: List[int]
        :rtype: List[int]
        """

        
        jinwei,i = 0,1
        while i <= len(digits):
            if i == 1:
                sum = digits[-i]+jinwei+1
            else:
                sum = digits[-i]+jinwei
            jinwei = 1 if sum > 9 else 0
            digits [-i] = sum % 10
            i += 1
        if jinwei == 1:
            digits.insert(0,1)
        return digits 


s=Solution()
s.plusOne([9,9,9])

# [9]
# [0]
# [1,9]
# [9,9]


